home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PROGEDIT
/
0748.ZIP
/
SHIFT
< prev
next >
Wrap
Text File
|
1986-12-29
|
1KB
|
40 lines
/* This macro shifts a marked block of text left or right. You can do */
/* the same thing my marking the area to indent, using the 'indent' */
/* block command, and using the arrow keys. */
shift()
{
int line1, line2;
int n, j;
/* Prompt the user for the indent width, and check for a bad number. */
n = atoi(get_tty_str("How many spaces (default 2) ?"));
if (n == 0) n = 2;
line1 = marked_line(); /* get the marked range */
line2 = currlinenum();
goline(line1); /* set the cursor to the start of the area */
gobol();
while (currlinenum() <= line2)
{
if (n >= 0) /* shift rightwards - insert n spaces */
{
gobol();
insert(repstr(" ", n));
}
else /* a negative amount means to shift leftwards */
{
j = -n;
while (j > 0) /* delete 'n' characters */
{
delchar();
j = j - 1;
}
}
down(); /* move down to the next line */
}
clear_mark(); /* remove any existing marks */
}